﻿namespace EasyGo.Services
{
    using EasyGo.Data;
    using StructureMap;
    using System;
    using System.Web;
    using System.Web.Caching;

    public abstract class Service
    {
        protected void SaveChanges()
        {
            var unit = ObjectFactory.GetInstance<IUnitOfWork>();
            unit.CommitChanges();
        }

        protected void SetCacheItem(string key, object value)
        {
             HttpContext.Current.Cache.Add(key,value,null,DateTime.MaxValue,Cache.NoSlidingExpiration,CacheItemPriority.Normal,null );
        }

        protected void RemoveCacheItem(string key)
        {
            HttpContext.Current.Cache.Remove(key);
        }

        protected object GetCacheItem(string key)
        {
            return HttpContext.Current.Cache.Get(key);
        }
    }
}
